package com.github.bobjoy.java.rpc.consumer;

import com.github.bobjoy.java.rpc.api.EchoService;
import com.github.bobjoy.java.rpc.provider.RpcImporter;
import com.github.bobjoy.java.rpc.provider.service.EchoServiceImpl;

import java.net.InetSocketAddress;

public class RpcClient {

    private static void invoke(String ping) {
        RpcImporter<EchoService> importer = new RpcImporter<>();
        EchoService service = importer.importer(EchoServiceImpl.class, new InetSocketAddress("localhost", 8000));
        System.out.println(service.echo(ping));
    }

    public static void main(String[] args) {
        for (int i=0; i<5; i++) {
            invoke("Are you " + i + "？");
        }
    }

}
